get_call_stack_size

This function returns the number of functions that are currently on the stack.

double get_call_stack_size()

Parameters:
None.

Return value:
The number of functions that are on the call stack (see remarks).

Remarks:
The call stack is a list of the functions that are being executed recursively. This function is useful when you wish to check how many functions that are currently on the stack, without retrieving all the information about each one.

Example:
/*
This example makes a few recursive function calls and then prints the stack size.
*/

int number_of_calls_to_make=100;

void main()
{
counter_function();
}

void counter_function()
{
number_of_calls_to_make-=1;
if(number_of_calls_to_make==0)
{
alert("Stack size", "The stack size is " + get_call_stack_size() + ".");
/*
The output should be 101, as main is also being called. After this point, we return back through the entire chain of functions and finally exit when we get to main.
*/
return;
}
counter_function();
}